//
//  FYPicPikerCollectionViewCell.swift
//  dugeweibo
//
//  Created by pelesys on 16/8/7.
//  Copyright © 2016年 杜方宜. All rights reserved.
//

import UIKit

class FYPicPikerCollectionViewCell: UICollectionViewCell {
    //MARK:-控件属性
    @IBOutlet weak var addPhotoBtn: UIButton!

    @IBOutlet weak var imageView: UIImageView!
 
    @IBOutlet weak var removePhotoBtn: UIButton!
    //MARK:-定义属性
    var image : UIImage? {
    didSet{
        if image != nil {
            imageView.image = image
            addPhotoBtn.isUserInteractionEnabled = false
            removePhotoBtn.isHidden = false
        }else{
            imageView.image = nil
            addPhotoBtn.isUserInteractionEnabled = true
            removePhotoBtn.isHidden = true
        }
    }
    }
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }
   
    //MARK:-监听事件
    
    @IBAction func addPhotoClick(sender: AnyObject) {
        NotificationCenter.default.post(name: NSNotification.Name(rawValue: PicPickerAddPhotoNote) , object: nil)
    }
    
    @IBAction func removePhotoClick(sender: UIButton) {
        NotificationCenter.default.post(name:NSNotification.Name(PicPickerRemovePhotoNote), object: imageView.image)
    }

}
